package tr.edu.metu.is.mega.client.service;

import java.util.Map;

import tr.edu.metu.is.mega.common.ValidationAttributeValue;
import tr.edu.metu.is.mega.common.ValidationConstraint;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * GWT remote service interface for software feature/category definition
 * management.
 */
@RemoteServiceRelativePath("../GwtValidationService")
public interface GwtValidationService extends RemoteService {

    /**
     * Utility class for simplifying access to the instance of async service.
     */
    public static class Util {

        private static GwtValidationServiceAsync instance;

        /**
         * Returns singleton instance of this.
         * 
         * @return singleton instance of this
         */
        public static GwtValidationServiceAsync getInstance() {
            if (instance == null) {
                instance = GWT.create(GwtValidationService.class);
            }
            return instance;
        }
    }

    /**
     * Returns validation constraints of a DTO class.
     * 
     * @param clazz class type
     * @return map of validation constraints (field - constraint - value)
     */
    Map<String, Map<ValidationConstraint, ValidationAttributeValue>> getValidationConstraints(String clazz);

}
